#include "comm.hpp"
#include <unistd.h>
#include <iostream>

int main()
{
    FIFO fifo;
    char buff[1024]; buff[0] = '\0';
    int fd = open(fifo.getFifoName(), O_RDONLY);
    while(true)
    {
        ssize_t s = read(fd, buff, sizeof(buff));
        if(s > 0)
        {
            buff[s] = '\0';
            std::cout << "Server get a meg: " << buff << std::endl;
            log(LOG, "Server get a meg...");
        }
        else if(s == 0) { break; }
        else { log(ERROR, "%s:line:%d:read err", __FILE__, __LINE__); exit(1); }
    }
    log(LOG, "server quit");
    return 0;
}